package com.edu.netty.io;

import java.net.Socket;
import java.nio.charset.StandardCharsets;

/**
 * <p>
 * IO客户端
 * </p>
 *
 * @author jpge
 * @since 2024-03-29
 */
public class IOClient {

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            new IOClientThread().start();
        }
    }

    static class IOClientThread extends Thread {
        @Override
        public void run() {
            try {
                Socket socket = new Socket("localhost", 10086);
                while (true) {
                    socket.getOutputStream().write(",IO TEST".getBytes(StandardCharsets.UTF_8));
                    socket.getOutputStream().flush();

                    Thread.sleep(1000);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
